package com.lagou.service;

import com.lagou.pojo.Article;
import com.lagou.repository.ArticleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class ArticleService {

    @Autowired
    ArticleRepository articleRepository;


    /**
     * 分页查询
     * @param pageNum  当前所在页数
     * @param pageSize  每页的记录数
     * @return
     */
    public Page<Article> pagingFindArticle(int pageNum, int pageSize){
        Pageable pageable = PageRequest.of(pageNum, pageSize);
        Page<Article> articles =articleRepository.findAll(pageable);
        return articles;
    }
}
